/**
 * Created by ls-PC on 2016/7/26.
 */

var moment = require('moment');
module.exports=function(orm,db){

    var Feedback =db.define('feedback',{
        feedbacktext      : { type: 'text', required: true },
        feedbacktime : { type: 'date', required: true, time: true }
    },{
        hooks: {
            beforeValidation: function () {
                this.feedbacktime = new Date();
            }
        },

        methods: {
            serialize: function () {
                return {
                    id:this.id,
                    feedbacktext      : this.feedbacktext,
                    feedbacktime : moment(this.feedbacktime).fromNow()
                }
            }
        }
    })
}

